<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/task.jsp"%>
<%@ include file="/common/user.jsp"%>
<%
    String ids = input.getDesc("group_patient_ids", "");
    String[] _ids = ids.split("\\|");
    if ("".equals(ids) || isEmpty(_ids)) {
        msg = new Message(30062, "请选择要删除的用户");
        Tools.encryptPrint(out, msg);
        return;
    }
    MyTask task = new MyTask(_ids.length);
    final Integer _hospital = hospital;
    for (int i = 0; i < _ids.length; i++) {
        task.runTask(task.new MyRunnable(task.new DBOperate() {

				@Override
				public Object operate(Object... objects) {
                    List<GroupPatient> groupPatients = QBuilder.db("basedb").select().from("GroupPatient").where(new Where("status = ", STATUS_ENABLE).and("hospital =", _hospital).and("id=", Tools.getInt(objects[0]+"", 0))).query().getResultObj();
                    if (isEmpty(groupPatients)) {  // 不存在
                        return Tools.getInt(objects[0]+"", 0);
                    }
                    GroupPatient groupPatient = groupPatients.get(0);
                    groupPatient.setStatus(STATUS_DISABLE);
                    DBTools.db("basedb").modItem(groupPatient, groupPatient.getId());
					return null;
				}
			}, i, new Object[]{_ids[i]}));
    }
    task.stopTask();
    Object[] results = task.getResult();
    msg.put("data", results);
    Tools.encryptPrint(out, msg);
%>
